# -*- coding: utf-8 -*-  
"""  
@author     : Mengnf  
@github     : https://gitee.com/mengnf  
@software   : PyCharm   
@file       : manufacturers  
@create     : 2024-11-19 21:03  
@description：
"""

from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import SearchFilter, OrderingFilter

from drf_admin.utils.views import AdminViewSet
from ic.models import Manufacturers
from ic.serializers.manufacturers import ManufacturersSerializer


class ManufacturersViewSet(AdminViewSet):
    """
    create:
    新增

    用户新增, status: 201(成功), return: 新增用户信息

    destroy:
    删除

    用户删除, status: 204(成功), return: None

    multiple_delete:
    批量删除

    用户批量删除, status: 204(成功), return: None

    update:
    修改

    用户修改, status: 200(成功), return: 修改后的用户信息

    partial_update:
    局部修改

    用户局部修改(激活/锁定), status: 200(成功), return: 修改后的用户信息

    list:
    获取列表

    用户列表信息, status: 200(成功), return: 用户信息列表

    retrieve:
    详情

    用户详情信息, status: 200(成功), return: 单个用户信息详情
    """
    queryset = Manufacturers.objects.all()
    serializer_class = ManufacturersSerializer
    filter_backends = (DjangoFilterBackend, SearchFilter, OrderingFilter)
    search_fields = ('code', 'name')
    ordering_fields = ('code',)
